home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* roomb.c */
- /* room code for Citadel bulletin board system */
- /************************************************************************/
-
- /************************************************************************/
- /* History */
- /* */
- /* 86Aug16 HAW Kill history in here due to space problems. */
- /* 85Jan16 JLS Fix getText so console starting CR creates blank msg. */
- /* 84Jun28 JLS Enhancement: Creator of a room is listed in Aide>. */
- /* 84Apr04 HAW Start upgrade to BDS 1.50a. */
- /* 83Feb26 CrT bug in makeRoom when out of rooms fixed. */
- /* 83Feb26 CrT matchString made caseless, normalizeString() */
- /* 83Feb26 CrT "]" directory prompt, user name before prompts */
- /* 82Dec06 CrT 2.00 release. */
- /* 82Nov02 CrT Cleanup prior to V1.2 mods. */
- /* 82Nov01 CrT Proofread for CUG distribution. */
- /* 82Mar27 dvm conversion to v. 1.4 begun */
- /* 82Mar25 dvm conversion for TRS-80/Omikron test started */
- /* 81Dec21 CrT Log file... */
- /* 81Dec20 CrT Messages... */
- /* 81Dec19 CrT Rooms seem to be working... */
- /* 81Dec12 CrT Started. */
- /************************************************************************/
-
- #include "ctdl.h"
-
- /************************************************************************/
- /* Contents */
- /* */
- /* coreGetYesNo() core for conGetYesNo() and getYesNo() */
- /* conGetYesNo() prompts for a yes/no response from CON */
- /* editText() handles the end-of-message-entry menu */
- /* findRoom() find a free room */
- /* getNumber() prompt user for a number, limited range */
- /* getString() read a string in from user */
- /* getText() reads a message in from user */
- /* getYesNo() prompts for a yes/no response */
- /* givePrompt() gives usual "THISROOM>" prompt */
- /* # good_path() gets subdirectory path from sysop */
- /* indexRooms() build RAM index to ctdlroom.sys */
- /* initialArchive() does initial archive of a room */
- /* makeRoom() make new room via user dialogue */
- /* matchString() search for given string */
- /* noteRoom() enter room into RAM index */
- /* renameRoom() sysop special to rename rooms */
- /* replaceString() string-substitute for message entry */
- /* */
- /* # -- operating system dependent function. */
- /************************************************************************/
-
- /************************************************************************/
- /* External variable declarations in ROOMB.C */
- /************************************************************************/
- char *public_str = "Public";
- char *private_str = "Private";
- char *perm_str = "Permanent";
- char *temp_str = "Temporary";
- char exChar = '?';
-
- /************************************************************************/
- /* External variable definitions for ROOMB.C */
- /************************************************************************/
- extern struct aRoom roomBuf; /* Room buffer */
- extern struct rTable roomTab[]; /* RAM index */
- extern FILE *roomfl; /* Room file descriptor */
- extern struct config cfg; /* Other variables */
- extern struct msgB msgBuf; /* Message buffer */
- extern struct msgB tempMess; /* For held messages */
- extern struct logBuffer logBuf; /* Person buffer */
- extern struct netBuffer netBuf;
- extern ulong roomHiMsgs[];
- extern int masterCount;
- extern int thisRoom; /* Current room */
- extern char remoteSysop;
- extern char outFlag; /* Output flag */
- extern char loggedIn; /* Logged in? */
- extern char haveCarrier; /* Have carrier? */
- extern char onConsole; /* How about on Console? */
- extern char whichIO; /* Where is I/O? */
- extern char debug; /* Debug flag */
- extern char expert; /* expert? */
- extern char *baseRoom;
- extern char heldMessage;
- extern char echo;
- extern char echoChar;
- extern char *confirm;
-
- /************************************************************************/
- /* External function definitions for ROOMB.C */
- /************************************************************************/
- char *formRoom();
- char iChar();
- char getYesNo();
- char coreGetYesNo();
- char conGetYesNo();
- char toUpper();
- int fread();
-
- /************************************************************************/
- /* conGetYesNo() prompts for a yes/no response from CONSOLE only */
- /************************************************************************/
- char conGetYesNo(prompt)
- char *prompt;
- {
- return coreGetYesNo(prompt, TRUE);
- }
-
- /************************************************************************/
- /* coreGetYesNo() prompts for a yes/no response given fn for echo */
- /************************************************************************/
- char coreGetYesNo(prompt, consoleOnly)
- char *prompt;
- int consoleOnly;
- {
- int toReturn;
- char iChar(), getCh(), (*inputFn)();
- int printf(), mPrintf(), (*outputFn)();
- #define write_CR() (!consoleOnly) ? doCR() : printf("\n")
-
- inputFn = (consoleOnly) ? getCh : iChar;
- outputFn = (consoleOnly) ? printf : mPrintf;
-
- for (write_CR(), toReturn = ERROR; toReturn == ERROR && onLine(); ) {
- outFlag = IMPERVIOUS;
- (*outputFn)("%s? (Y/N): ", prompt);
-
- switch (toUpper((*inputFn)())) {
- case 'Y': toReturn = TRUE ; break;
- case 'N': toReturn = FALSE; break;
- }
- write_CR();
- }
- outFlag = OUTOK;
- return toReturn;
- }
-
- /************************************************************************/
- /* editText() handles the end-of-message-entry menu. */
- /* return TRUE to save message to disk, */
- /* FALSE to abort message, and */
- /* ERROR if user decides to continue */
- /************************************************************************/
- int editText(buf, lim)
- char *buf;
- int lim;
- {
- extern char *ALL_LOCALS, *WRITE_LOCALS, *R_SH_MARK;
-
- do {
- outFlag = IMPERVIOUS;
- mPrintf("\n entry cmd: ");
- switch (toUpper(iChar())) {
- case 'A':
- mPrintf("bort\n ");
- if (getYesNo(confirm)) {
- return FALSE;
- }
- break;
- case 'C':
- mPrintf("ontinue");
- doCR();
- return ERROR;
- case 'P':
- mPrintf("rint formatted\n ");
- doCR();
- outFlag = OUTOK;
- mPrintf( " ");
- printDate();
- if (loggedIn)
- mPrintf(" from %s", msgBuf.mbauth);
- if (thisRoom == MAILROOM)
- mPrintf(" to %s", msgBuf.mbto);
- if (msgBuf.mbaddr[0] && strCmpU(msgBuf.mbaddr, R_SH_MARK) != 0)
- mPrintf(" (on %s)", wrNetId(msgBuf.mbaddr));
- if (msgBuf.mboname[0])
- mPrintf(" @%s", msgBuf.mboname);
- doCR();
- mFormat(buf);
- break;
- case 'R':
- mPrintf("eplace string\n ");
- replaceString(buf, lim);
- break;
- case 'S':
- mPrintf("ave buffer\n ");
- return TRUE;
- case 'H':
- mPrintf("old message for later\n ");
- if (heldMessage) {
- mPrintf("Message already being held!\n ");
- break;
- }
- mPrintf("Message held\n ");
- movmem(&msgBuf, &tempMess, sizeof msgBuf);
- heldMessage = TRUE;
- return FALSE;
- case '?':
- tutorial("edit.mnu");
- break;
- default:
- if (!expert) tutorial("edit.mnu");
- else mPrintf(" ? (Type '?' for menu)\n \n");
- break;
- }
- } while (onLine());
- return FALSE;
- }
-
- /************************************************************************/
- /* findRoom() returns # of free room if possible, else ERROR */
- /************************************************************************/
- int findRoom()
- {
- int roomRover;
-
- for (roomRover = 0; roomRover < MAXROOMS; roomRover++) {
- if (roomTab[roomRover].rtflags.INUSE == 0) return roomRover;
- }
- return ERROR;
- }
-
- /************************************************************************/
- /* getNumber() prompts for a number in (bottom, top) range. */
- /************************************************************************/
- long getNumber(prompt, bottom, top)
- char *prompt;
- long bottom;
- long top;
- {
- long try;
- long atoi();
- char numstring[NAMESIZE];
-
- do {
- getString(prompt, numstring, NAMESIZE, FALSE, ECHO);
- try = atoi(numstring);
- if (try < bottom) mPrintf("Sorry, must be at least %ld\n", bottom);
- if (try > top ) mPrintf("Sorry, must be no more than %ld\n", top);
- } while ((try < bottom || try > top) && onLine());
- return (long) try;
- }
-
- /************************************************************************/
- /* getString() gets a string from the user. */
- /************************************************************************/
- getString(prompt, buf, lim, QuestIsSpecial, doEcho)
- char *prompt;
- char *buf;
- char doEcho;
- int lim; /* max # chars to read */
- char QuestIsSpecial; /* Return immediately on '?' input? */
- {
- char c, oldEcho;
- int i;
-
- outFlag = IMPERVIOUS;
-
- if (strLen(prompt) > 0) {
- doCR();
- mPrintf("Enter %s\n : ", prompt, lim);
- }
-
- oldEcho = echo;
- if (!doEcho) {
- echo = NEITHER;
- echoChar = 'X';
- }
-
- i = 0;
- while (
- c = iChar(),
-
- c != NEWLINE
- && i < lim
- && onLine()
- ) {
- outFlag = OUTOK;
-
- /* handle delete chars: */
- if (c == BACKSPACE) {
- oChar(' ');
- oChar(BACKSPACE);
- if (i > 0) i--;
- else {
- oChar(' ');
- oChar(BELL);
- }
- } else buf[i++] = c;
-
- if (i >= lim) {
- oChar(BELL);
- oChar(BACKSPACE); i--;
- }
-
- /* kludge to return immediately on single '?': */
- if (QuestIsSpecial && *buf == exChar) {
- doCR();
- break;
- }
- }
- echo = oldEcho;
- buf[i] = '\0';
- }
-
- /************************************************************************/
- /* getText() reads a message from the user */
- /* Returns TRUE if user decides to save it, else FALSE */
- /************************************************************************/
- char getText(uploading)
- char uploading;
- {
- #ifdef NEED_VISIBLE
- char visible();
- #endif
- extern char *R_SH_MARK;
- char c, *buf, beeped = FALSE;
- int i, toReturn, lim, putBufChar();
-
- buf = msgBuf.mbtext;
- buf[-1] = NEWLINE;
-
- if (!uploading) {
- if (!expert) {
- tutorial("entry.blb");
- mPrintf("Enter message (end with empty line)");
- }
- outFlag = OUTOK;
- doCR();
- mPrintf(" ");
- printDate();
- if (loggedIn) mPrintf("from %s", msgBuf.mbauth);
- if (thisRoom == MAILROOM) mPrintf(" to %s", msgBuf.mbto);
- if (msgBuf.mbaddr[0] &&
- strCmpU(msgBuf.mbaddr, R_SH_MARK) != SAMESTRING)
- mPrintf(" (on %s)", wrNetId(msgBuf.mbaddr));
- if (msgBuf.mboname[0]) mPrintf( " @%s", msgBuf.mboname);
- doCR();
-
- if (msgBuf.mbtext[0]) {
- outFlag = OUTOK;
- mFormat(buf);
- outFlag = OUTOK;
- doCR();
- }
- outFlag = OUTOK;
- lim = MAXTEXT - 1;
- }
- else {
- if (!expert) tutorial("wcupload.blb");
- if (!getYesNo("Ready for WC transfer"))
- return FALSE;
- masterCount = 0;
- if (!readFile(putBufChar))
- return FALSE;
- }
-
- do {
- i = strLen(buf);
- if (!uploading)
- while (
- !(
- (c=iChar()) == NEWLINE &&
- (buf[i-1] == NEWLINE || i == 0)
- )
- && i < lim
- && onLine()
- ) {
- if (c != BACKSPACE) {
- if (c != 0) buf[i++] = c;
- if (i > MAXTEXT - 80 && !beeped) {
- beeped = TRUE;
- oChar(BELL);
- }
- }
- else {
- /* handle delete chars: */
- oChar(' ');
- oChar(BACKSPACE);
- if (i > 0 && buf[i-1] != NEWLINE) i--;
- else oChar(BELL);
- }
-
- buf[i] = 0x00; /* null to terminate message */
-
- if (i == lim) mPrintf(" buffer overflow\n ");
- }
-
- toReturn = editText(buf, lim);
- uploading = FALSE;
- } while ((toReturn == ERROR) && onLine());
- if (toReturn == TRUE) { /* Filter null messages */
- toReturn = FALSE;
- for (i = 0; buf[i] != 0 && !toReturn; i++)
- toReturn = (buf[i] > ' ' && buf[i] < 127);
- }
- return toReturn;
- }
-
- /************************************************************************/
- /* getYesNo() prompts for a yes/no response */
- /************************************************************************/
- char getYesNo(prompt)
- char *prompt;
- {
- return coreGetYesNo(prompt, FALSE);
- }
-
- /************************************************************************/
- /* givePrompt() prints the usual "CURRENTROOM>" prompt. */
- /************************************************************************/
- givePrompt()
- {
- outFlag = IMPERVIOUS;
- doCR();
- if (loggedIn) printf("(%s)\n", logBuf.lbname);
- if (!expert) {
- mPrintf("<G>oto%s%s <H>elp",
- (thisRoom == MAILROOM || loggedIn || cfg.unlogReadOk) ? " <N>ew" : "",
- (thisRoom == MAILROOM || loggedIn || cfg.unlogEnterOk) ? " <E>nter" : "");
- doCR();
- }
-
- mPrintf("%s ", formRoom(thisRoom, FALSE));
-
- if (strCmp(roomBuf.rbname, roomTab[thisRoom].rtname) != SAMESTRING) {
- printf("thisRoom=%d, rbname=-%s-, rtname=-%s-\n", thisRoom,
- roomBuf.rbname, roomTab[thisRoom].rtname);
- crashout("Dependent variables mismatch!");
- }
- outFlag = OUTOK;
- }
-
- /************************************************************************/
- /* good_path() Gets a valid path from the sysop. Drive should be */
- /* set already. */
- /************************************************************************/
- good_path(buffer, size)
- char *buffer;
- int size;
- {
- char *cd, *gcdir();
- char gooddir;
-
- cd = gcdir("");
- buffer[0] = '\\';
- do {
- mPrintf("\n Path: \\");
- getString("", buffer+1, size - 1, FALSE, ECHO, FALSE);
- gooddir = ((chdir(buffer) != EOF) || buffer[1] == '?');
- if (!gooddir) printf("Directory not found.\n");
- } while (!gooddir);
- chdir(cd);
- free(cd);
- }
-
- /************************************************************************/
- /* indexRooms() -- build RAM index to CTDLROOM.SYS, by CITADEL, to */
- /* delete empty rooms. */
- /************************************************************************/
- indexRooms()
- {
- int goodRoom, m, slot;
-
- for (slot = 0; slot < MAXROOMS; slot++) {
- if (roomTab[slot].rtflags.INUSE == 1) {
- goodRoom = FALSE;
- if (roomTab[slot].rtlastMessage > cfg.oldest ||
- roomTab[slot].rtflags.PERMROOM == 1) {
- goodRoom = TRUE;
- }
-
- if (!goodRoom) {
- getRoom(slot);
- roomBuf.rbflags.INUSE = 0;
- roomBuf.rbflags.MSDOSDIR = 0;
- roomBuf.rbflags.PERMROOM = 0;
- roomBuf.rbflags.INUSE = 0;
- putRoom(slot);
- strCat(msgBuf.mbtext, roomBuf.rbname);
- strCat(msgBuf.mbtext, "> ");
- noteRoom();
- }
- }
- }
- }
-
- /************************************************************************/
- /* makeRoom() constructs a new room via dialogue with user. */
- /************************************************************************/
- makeRoom()
- {
- char *nm[NAMESIZE];
- char *oldName[NAMESIZE];
- int i;
-
- /* update lastMessage for current room: */
- logBuf.lbgen[thisRoom] = roomBuf.rbgen << GENSHIFT;
-
- strCpy(oldName, roomBuf.rbname);
- if ((thisRoom = findRoom()) == ERROR) {
- indexRooms(); /* try and reclaim an empty room */
- if ((thisRoom = findRoom()) == ERROR) {
- mPrintf(" ?no room, sorry");
- /* may have reclaimed old room, so: */
- if (roomExists(oldName) == ERROR) strCpy(oldName, baseRoom);
- getRoom(roomExists(oldName));
- return;
- }
- }
-
- getNormStr("name for new room", nm, NAMESIZE, ECHO);
- if (strLen(nm) == 0) {
- if (roomExists(oldName) == ERROR) strCpy(oldName, baseRoom);
- getRoom(roomExists(oldName));
- return ;
- }
-
- if (roomExists(nm) >= 0) {
- mPrintf(" A '%s' already exists.\n", nm);
- /* may have reclaimed old room, so: */
- if (roomExists(oldName) == ERROR) strCpy(oldName, baseRoom);
- getRoom(roomExists(oldName));
- return;
- }
- if (!expert) tutorial("newroom.blb");
-
- roomBuf.rbflags.INUSE = TRUE;
- roomBuf.rbflags.PERMROOM =
- roomBuf.rbflags.MSDOSDIR =
- roomBuf.rbflags.UPLOAD =
- roomBuf.rbflags.DOWNLOAD =
- roomBuf.rbflags.SHARED =
- roomBuf.rbflags.ARCHIVE =
- roomBuf.rbflags.rflag3 =
- roomBuf.rbflags.rflag4 =
- roomBuf.rbflags.rflag5 =
- roomBuf.rbflags.rflag6 =
- roomBuf.rbflags.rflag7 =
- roomBuf.rbflags.rflag8 =
- roomBuf.rbflags.rflag9 =
- roomBuf.rbflags.rflag10 =
- roomBuf.rbflags.rflag11 =
- roomBuf.rbflags.rflag12 = FALSE;
-
- if (getYesNo(" Make room public")) roomBuf.rbflags.PUBLIC = TRUE;
- else roomBuf.rbflags.PUBLIC = FALSE;
-
- mPrintf("'%s', a %s room",
- nm,
- roomBuf.rbflags.PUBLIC == 1 ? "public" : "private"
- );
-
- if(!getYesNo("Install it")) {
- /* may have reclaimed old room, so: */
- if (roomExists(oldName) == ERROR) strCpy(oldName, baseRoom);
- getRoom(roomExists(oldName));
- return;
- }
-
- strCpy(roomBuf.rbname, nm);
- for (i = 0; i < MSGSPERRM; i++) {
- roomBuf.msg[i].rbmsgNo = 0l; /* mark all slots empty */
- roomBuf.msg[i].rbmsgLoc = 0 ;
- }
- roomBuf.rbgen = (roomTab[thisRoom].rtgen + 1) % MAXGEN;
-
- noteRoom(); /* index new room */
- putRoom(thisRoom);
-
- /* update logBuf: */
- logBuf.lbgen[thisRoom] = roomBuf.rbgen << GENSHIFT;
- sPrintf(msgBuf.mbtext, "%s> created by %s", nm, logBuf.lbname);
- aideMessage(FALSE);
- roomHiMsgs[thisRoom] = 0l;
- }
-
- /************************************************************************/
- /* matchString() searches for match to given string. Runs backward*/
- /* through buffer so we get most recent error first. */
- /* Returns loc of match, else ERROR */
- /************************************************************************/
- char *matchString(buf, pattern, bufEnd)
- char *buf, *pattern, *bufEnd;
- {
- char *loc, *pc1, *pc2;
- char foundIt;
-
- for (loc = bufEnd, foundIt = FALSE; !foundIt && --loc >= buf;) {
- for (pc1 = pattern, pc2 = loc, foundIt = TRUE ; *pc1 && foundIt;) {
- if (! (toLower(*pc1++) == toLower(*pc2++))) foundIt = FALSE;
- }
- }
-
- return foundIt ? loc : NULL;
- }
-
- /************************************************************************/
- /* getNormStr() gets a string and deletes leading */
- /* & trailing blanks etc. */
- /************************************************************************/
- getNormStr(prompt, s, size, doEcho)
- char *s, *prompt;
- char doEcho;
- int size;
- {
- char *pc;
-
- getString(prompt, s, size, FALSE, doEcho);
- pc = s;
-
- /* find end of string */
- while (*pc) {
- if (*pc < ' ') *pc = ' '; /* zap tabs etc... */
- pc++;
- }
-
- /* no trailing spaces: */
- while (pc>s && isSpace(*(pc-1))) pc--;
- *pc = '\0';
-
- /* no leading spaces: */
- while (*s == ' ') {
- for (pc=s; *pc; pc++) *pc = *(pc+1);
- }
-
- /* no double blanks */
- for (; *s;) {
- if (*s == ' ' && *(s+1) == ' ') {
- for (pc=s; *pc; pc++) *pc = *(pc+1);
- }
- else s++;
- }
- }
-
- /************************************************************************/
- /* noteRoom() -- enter room into RAM index array. */
- /************************************************************************/
- noteRoom()
- {
- int i;
- ulong last;
-
- last = 0l;
- for (i = 0; i < MSGSPERROOM; i++) {
- if (roomBuf.msg[i].rbmsgNo > last) {
- last = roomBuf.msg[i].rbmsgNo;
- }
- }
- roomTab[thisRoom].rtlastMessage = last ;
- strCpy(roomTab[thisRoom].rtname, roomBuf.rbname) ;
- roomTab[thisRoom].rtgen = roomBuf.rbgen ;
- movmem(&roomBuf.rbflags, &roomTab[thisRoom].rtflags,
- sizeof roomBuf.rbflags);
- }
-
- /************************************************************************/
- /* renameRoom() is sysop special fn */
- /* Returns: TRUE on success else FALSE */
- /************************************************************************/
- renameRoom()
- {
- char nm[NAMESIZE];
- char buffer[200];
- char c, goodOne, wasDirectory, wasArchive, wasShare;
- int r;
-
- if ( /* clearer than "thisRoom <= AIDEROOM"*/
- thisRoom == LOBBY
- ||
- thisRoom == MAILROOM
- ||
- thisRoom == AIDEROOM
- ) {
- mPrintf("? -- may not edit this room.\n ");
- return FALSE;
- }
-
- wasDirectory = roomBuf.rbflags.MSDOSDIR;
- wasArchive = roomBuf.rbflags.ARCHIVE;
- wasShare = roomBuf.rbflags.SHARED;
-
- formatSummary(buffer);
- sPrintf(msgBuf.mbtext, "%s, formerly ", formRoom(thisRoom, FALSE));
- strCat(msgBuf.mbtext, buffer);
-
- mPrintf("\n %s is a %s\n ", formRoom(thisRoom, FALSE), buffer);
-
- if (!getYesNo("Edit room")) return FALSE;
-
- if (getYesNo("Change name")) {
- getNormStr("new room name", nm, NAMESIZE, ECHO);
- r = roomExists(nm);
- if (r >= 0 && r != thisRoom) {
- mPrintf("A %s exists already!\n", nm);
- } else {
- strCpy(roomBuf.rbname, nm); /* also in room itself */
- }
- }
- roomBuf.rbflags.INUSE = TRUE;
-
- if (getYesNo("Public room")) {
- roomBuf.rbflags.PUBLIC = TRUE;
- } else {
- roomBuf.rbflags.PUBLIC = FALSE;
- if (getYesNo("Cause non-aide users to forget room")) {
- roomBuf.rbgen = (roomBuf.rbgen +1) % MAXGEN;
- logBuf.lbgen[thisRoom] = (logBuf.lbgen[thisRoom] & CALLMASK) +
- (roomBuf.rbgen << GENSHIFT);
- roomTab[thisRoom].rtgen = roomBuf.rbgen;
- }
- }
-
- if (!onConsole && !remoteSysop) roomBuf.rbflags.MSDOSDIR = wasDirectory;
- else if (getYesNo("Directory room")) {
- roomBuf.rbflags.MSDOSDIR = TRUE;
-
- for (goodOne = FALSE; !goodOne; ) {
- getString("disk", nm, NAMESIZE, FALSE, ECHO);
- c = toUpper(nm[0]);
- if (c>='A' && c<='Z') {
- roomBuf.rbdisk = c - 'A';
- goodOne = TRUE;
- } else mPrintf("?");
- }
- setSpace(roomBuf.rbdisk, "");
-
- for (goodOne = FALSE; !goodOne; ) {
- getString("directory (empty entry means use current directory)",
- nm, 9, FALSE, ECHO);
- if (index(nm, ' ') != NULL)
- mPrintf("No spaces in directory names!");
- else if (index(nm, '\\') != NULL)
- mPrintf("No '\\'s in directory names!");
- else if (strLen(nm) == 0) {
- goodOne = TRUE;
- strCpy(roomBuf.rbdirname, nm);
- }
- else if (chdir(nm) != EOF) {
- mPrintf("%s exists. ", nm);
- goodOne = getYesNo("Use it");
- chdir("..");
- if (goodOne)
- strCpy(roomBuf.rbdirname, nm);
- }
- else {
- mPrintf("%s does not exist. ", nm);
- goodOne = getYesNo("Create");
- if (goodOne) {
- if (mkdir(nm) == EOF) {
- mPrintf("?ERROR CREATING!");
- roomBuf.rbflags.MSDOSDIR = FALSE;
- }
- else strCpy(roomBuf.rbdirname, nm);
- }
- }
- }
- setSpace(cfg.homeDisk, "");
- }
- else
- roomBuf.rbflags.MSDOSDIR = FALSE;
-
- if (roomBuf.rbflags.MSDOSDIR == TRUE || getYesNo("permanent")) {
- roomBuf.rbflags.PERMROOM = TRUE;
- }
- else
- roomBuf.rbflags.PERMROOM = FALSE;
-
- if ((onConsole || remoteSysop)) {
- if (roomBuf.rbflags.MSDOSDIR == TRUE) {
- roomBuf.rbflags.UPLOAD = getYesNo("Are uploads allowed");
- roomBuf.rbflags.DOWNLOAD = getYesNo("Are downloads allowed");
- if (!roomBuf.rbflags.UPLOAD && !roomBuf.rbflags.DOWNLOAD)
- mPrintf("You're strange.\n ");
- }
-
- if ((roomBuf.rbflags.ARCHIVE = getYesNo("Should room be archived"))) {
- if (!wasArchive) {
- getString("filename", buffer, 198, FALSE, ECHO);
- if (!addArchiveList(thisRoom, buffer))
- roomBuf.rbflags.ARCHIVE = 0;
- else
- initialArchive(buffer);
- }
- }
-
- if (cfg.netParticipant &&
- (roomBuf.rbflags.SHARED = getYesNo("Network room"))) {
- mPrintf("%s (Empty line to end)", wasShared ?
- "Systems to add to network list for this room" :
- "Systems to network this room with");
- doCR();
- do {
- mPrintf(": ");
- getNormStr("", nm, NAMESIZE, ECHO);
- if (strLen(nm) != 0) addToList(nm);
- } while (strLen(nm) != 0);
- }
- }
-
- noteRoom();
- putRoom(thisRoom);
-
- sPrintf(msgBuf.mbtext+strLen(msgBuf.mbtext), ", has been edited to %s, ",
- formRoom(thisRoom, FALSE));
- formatSummary(msgBuf.mbtext + strLen(msgBuf.mbtext));
- sPrintf(msgBuf.mbtext+strLen(msgBuf.mbtext), ", by %s.", logBuf.lbname);
-
- aideMessage(FALSE);
- return TRUE;
- }
-
- /************************************************************************/
- /* formatSummary() formats a summary of the current room */
- /************************************************************************/
- formatSummary(buffer)
- char *buffer;
- {
- sPrintf(buffer,"a %s, %s, %sarchived %sdirectory room",
- roomBuf.rbflags.PUBLIC == 1 ? public_str : private_str,
- roomBuf.rbflags.PERMROOM == 1 ? perm_str : temp_str,
- roomBuf.rbflags.ARCHIVE == 1 ? "" : "non",
- roomBuf.rbflags.MSDOSDIR == 1 ? "" : "non");
- if (roomBuf.rbflags.MSDOSDIR == 1) {
- sPrintf(buffer+strLen(buffer), " (drive %c, directory %s, ",
- 'A'+roomBuf.rbdisk,
- (strLen(roomBuf.rbdirname) == 0 ? "is current directory" : roomBuf.rbdirname));
- sPrintf(buffer+strLen(buffer), "allows %suploads, %sdownloads)",
- (roomBuf.rbflags.UPLOAD) ? "" : "no ",
- (roomBuf.rbflags.DOWNLOAD) ? "" : "no ");
- }
- }
-
- /************************************************************************/
- /* replaceString() corrects typos in message entry */
- /************************************************************************/
- replaceString(buf, lim)
- char *buf;
- int lim;
- {
- char oldString[2*SECTSIZE];
- char newString[2*SECTSIZE];
- char *loc, *textEnd;
- char *pc;
- int incr, length;
- char *matchString();
- /* find terminal null */
- for (textEnd = buf, length = 0; *textEnd; length++, textEnd++);
-
- getString("string", oldString, (2*SECTSIZE), FALSE, ECHO);
- if ((loc=matchString(buf, oldString, textEnd)) == NULL) {
- mPrintf("?not found.\n ");
- return;
- }
-
- getString("replacement", newString, (2*SECTSIZE), FALSE, ECHO);
- if ( (strLen(newString)-strLen(oldString)) >= lim - length) {
- mPrintf("?Overflow!\n ");
- return;
- }
-
- /* delete old string: */
- for (pc=loc, incr=strLen(oldString); *pc=*(pc+incr); pc++);
- textEnd -= incr;
-
- /* make room for new string: */
- for (pc=textEnd, incr=strLen(newString); pc>=loc; pc--) {
- *(pc+incr) = *pc;
- }
-
- /* insert new string: */
- for (pc=newString; *pc; *loc++ = *pc++);
- }
-
- /************************************************************************/
- /* initialArchive() Does initial archive of a room */
- /************************************************************************/
- initialArchive(fn)
- char *fn;
- {
- int msgRover;
- ulong number;
-
- strCpy(tempMess.mbtext, msgBuf.mbtext);
- mPrintf("Doing the initial archive\n ");
- for (msgRover = 0; msgRover < MSGSPERROOM; msgRover++) {
- number = roomBuf.msg[msgRover].rbmsgNo;
- if (number > cfg.oldest && number < cfg.newest) {
- msgToDisk(fn, roomBuf.msg[msgRover].rbmsgNo,
- roomBuf.msg[msgRover].rbmsgLoc);
- mPrintf("%ld\n ", roomBuf.msg[msgRover].rbmsgNo);
- }
- }
- strCpy(msgBuf.mbtext, tempMess.mbtext);
- }
-
- /************************************************************************/
- /* addToList() Adds a system to a room networking list */
- /************************************************************************/
- addToList(name)
- char *name;
- {
- int slot, i, temp, gen;
- extern struct nodeRoomsTab *sharedRooms;
-
- if (name[0] == '?') {
- writeNet(FALSE);
- return ;
- }
-
- if ((slot = searchNameNet(name)) == ERROR) {
- mPrintf("No '%s' known", name);
- doCR();
- return;
- }
-
- getNet(slot);
-
- for (i = 0; i < SHARED_ROOMS; i++) {
- if ((netBuf.netRooms[i].srgen & 0x8000) != 0) { /* Salvage attempt */
- temp = netBuf.netRooms[i].srslot & 0x7fff;
- gen = netBuf.netRooms[i].srgen & 0x7fff;
-
- if (temp == thisRoom && gen == roomBuf.rbgen) {
- mPrintf("Already netting this room with %s", name);
- doCR();
- return ;
- }
-
- if (roomTab[temp].rtgen != gen || /* No longer exists! */
- roomTab[temp].rtflags.SHARED == 0) { /* Not netting */
- break;
- }
- }
- else
- break;
- }
-
- if (i == SHARED_ROOMS) {
- mPrintf("Sorry, already sharing %d rooms with %s", SHARED_ROOMS, name);
- return;
- }
-
- netBuf.netRooms[i].srslot = thisRoom;
- netBuf.netRooms[i].lastMess = 0l;
- netBuf.netRooms[i].srgen = roomBuf.rbgen + (unsigned) 0x8000;
- copy_array(netBuf.netRooms, sharedRooms[slot].rooms);
-
- dumpNodeRoom(TRUE);
- putNet(slot);
- }
-